package fr.vvins.core.catalog.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;


/**
 * Vin entity
 */
@Entity
@Table(schema="vvins",name="VV_VIN")
@PrimaryKeyJoinColumn(name="PRODUCT_ID")

public class Vin extends Product implements Serializable {

	private static final long serialVersionUID = -1548515713227113139L;
	@ManyToOne
	@JoinColumn(name="DESIGNATION_ID")
	private Designation designation;
	
	@ManyToOne
	@JoinColumn(name="DOMAIN_ID")
	private Domain domain;
	
	@ManyToOne
	@JoinColumn(name="VIGNERON_ID")
	private Vigneron vigneron;
	
	@ManyToOne
	@JoinColumn(name="REGION_ID")
	private Region region;
	
	@ManyToOne
	@JoinColumn(name="COUNTRY_ID")
	private Country country;
	
	@ManyToOne
	@JoinColumn(name="VARIETY_ID")
	private Variety variety;
	
	@Basic
	@Column(name="YEAR")
	private Integer year;
	
	@Basic
	@Column(name="ALCOHOL")
	private Integer alcohol;
	
	@ManyToOne
	@JoinColumn(name="COLOR_ID")
	private Color color;
	
	@ManyToOne
	@JoinColumn(name="CATEGORIZATION_ID")
	private Categorization categorization;
	
	@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
	@JoinTable(schema="vvins", name="VV_VIN_GRAPE", joinColumns=@JoinColumn(name="PRODUCT_ID"), inverseJoinColumns=@JoinColumn(name="GRAPE_ID"))
	private Set<Grape> grapes = new HashSet<Grape>(0);

	public Vin() {
	}

	public Vin(Designation designation, Domain domain, Vigneron vigneron,
			Region region, Country country, Product product, Variety variety,
			Integer year, Integer alcohol, Color color, Categorization categorization) {
		super();
		this.designation = designation;
		this.domain = domain;
		this.vigneron = vigneron;
		this.region = region;
		this.country = country;
		this.variety = variety;
		this.year = year;
		this.alcohol = alcohol;
		this.color = color;
		this.categorization = categorization;
	}

	public Designation getDesignation() {
		return designation;
	}

	public void setDesignation(Designation designation) {
		this.designation = designation;
	}

	public Domain getDomain() {
		return domain;
	}

	public void setDomain(Domain domain) {
		this.domain = domain;
	}

	public Vigneron getVigneron() {
		return vigneron;
	}

	public void setVigneron(Vigneron vigneron) {
		this.vigneron = vigneron;
	}

	public Region getRegion() {
		return region;
	}

	public void setRegion(Region region) {
		this.region = region;
	}

	public Country getCountry() {
		return country;
	}

	public void setCountry(Country country) {
		this.country = country;
	}

	public Variety getVariety() {
		return variety;
	}

	public void setVariety(Variety variety) {
		this.variety = variety;
	}

	public Integer getYear() {
		return year;
	}

	public void setYear(Integer year) {
		this.year = year;
	}

	public Integer getAlcohol() {
		return alcohol;
	}

	public void setAlcohol(Integer alcohol) {
		this.alcohol = alcohol;
	}

	public Color getColor() {
		return color;
	}

	public void setColor(Color color) {
		this.color = color;
	}

	public Categorization getCategorization() {
		return categorization;
	}

	public void setCategorization(Categorization categorization) {
		this.categorization = categorization;
	}

	public Set<Grape> getGrapes() {
		return grapes;
	}

	public void setGrapes(Set<Grape> grapes) {
		this.grapes = grapes;
	}
}
